<template>
	<div class="buymealfeepay">
		<payQRCode ref="payQRCode" @callback="closePay" @cancel="cancel"></payQRCode>
	</div>
</template>

<script>
	import payQRCode from "@/components/common/payQRCode";
	let vm;
	export default{
		components: {
			payQRCode
		},
		data(){
			return {
				param:{
					show:false,
					modalclose:false,
					isShowBtn:false
				},
				payType: {
					payIcon: '',
					payName: '',
					totalMoney:''
				},
				
			}
		},
		methods:{
			init(info){
				// debugger
				let payTitle='';
				let goods_num='';
				info.mealsData.forEach(ele=>{
					payTitle+=payTitle==''?ele.mealsName:('、'+ele.mealsName);
					goods_num+=goods_num==''?ele.mealsNum:('、'+ele.mealsNum);
				});
				let detail = {
					goods_name: payTitle,
					goods_num: goods_num,
					body: window.config.projectName + '- 支付'
				};
				//支付参数
				let paras = {
					outTradeNo: info.orderSigupId, //商户订单号
					totalFee: info.realMoney * 100,
					// totalFee: 1, //金额,暂时设为1分钱，便于测试
					body: window.config.projectName + '- 支付', //显示在支付界面的标题
					tradeType: 'NATIVE',
					detail: JSON.stringify(detail),
					campusId: this.$store.state.campusId
				};
				
				let payInfo ={
					orderParas:paras,
					payTitle:payTitle,
					payName:info.payName
				}
				
				vm.$refs.payQRCode.init(payInfo);
				
			},
			closePay(){
				vm.$emit('suceess');
			},
			cancel() {
				vm.$emit("back");
			}
		},
		mounted(){
			vm = this;
		}
	}
</script>